package com.myfoon.model.helper;

import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;

public class CacheHelper<T> {    
    private String cacheName;
    
    public CacheHelper(String cacheName) {
        this.cacheName = cacheName;
    }
    
    public NamedCache getInstance() {
        return CacheFactory.getCache(cacheName);
    }
    
    public T getValue(Object key) {
        Object value = getInstance().get(key);
        return value != null ? (T)value : null;
    }
    
    public void put(Object key, Object value) {
        getInstance().put(key, value);
    }

    public void setCacheName(String cacheName) {
        this.cacheName = cacheName;
    }

    public String getCacheName() {
        return cacheName;
    }
}
